'''
Created on Feb 24, 2016

@author: JimmyMo
'''
from __future__ import print_function
import cli.app
import emitlog
import schedule
import time

@cli.app.CommandLineApp
def command_line_app(app):
    interval = app.params.interval
    log_path = app.params.log_path
    pattern_path = app.params.pattern_path
    print("interval is %d..." % interval)
    print("log file path is %s..." % log_path)
    print("pattern file path is %s..." % pattern_path)
    schedule.every(interval).seconds.do(emitlog.job, log_path, pattern_path)
    while 1:
        schedule.run_pending()
        time.sleep(1)
#     emitlog.start(app.params.interval, app.params.log_path, app.params.pattern_path)
        
command_line_app.add_param("-v", "--interval", help="interval (seconds) to emit log", default=3, type=int)
command_line_app.add_param("-lp", "--log_path", help="file path to emit log", default='output.log', type=str)
command_line_app.add_param("-pp", "--pattern_path", help="log pattern path to read", default='log_json_patterns.conf', type=str)

if __name__ == "__main__":
    command_line_app.run()